import { BasicColumn, FormSchema } from '@/components/Table/index';

export const columns: BasicColumn[] = [
  {
    title: '角色类型',
    dataIndex: 'name',
    width: 150,
    align: 'center',
    sorter: true,
  },
  {
    title: '角色描述',
    dataIndex: 'description',
    width: 150,
    align: 'center',
    sorter: true,
  },
  {
    title: '角色对象类型',
    dataIndex: 'typeCodeString',
    width: 150,
    align: 'center',
    sorter: true,
  },
  {
    title: '隶属于',
    dataIndex: 'fullOrganizationName',
    width: 150,
    align: 'center',
    sorter: true,
  },
  {
    title: '是否启用',
    dataIndex: 'createdTime',
    width: 150,
    align: 'center',
    sorter: true,
    customRender: ({ record }) => {
      return record.isEnable ? '已启用' : '未启用'
    },
  },
  {
    title: '创建时间',
    dataIndex: 'createdTime',
    width: 150,
    align: 'center',
    sorter: true,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'keyWord',
    label: '关键字',
    component: 'Input',
    colProps: { span: 6 },
    componentProps: {
      placeholder: '请输入角色类型名称/编号',
    },
  },
  {
    field: 'OrganizationId',
    label: '所属机构',
    component: 'rwTreeSelect',
    colProps: { span: 6 },
    defaultValue: "",
    componentProps: {
      type: 'org',
      placeholder: '请选择所属机构',
    },
  },
];

export const formSchema: FormSchema[] = [
  {
    field: 'id',
    label: '',
    component: 'Input',
    show: false,
  },
  {
    field: 'name',
    label: '角色类型名称',
    required: true,
    component: 'Input',
    componentProps: {
      placeholder: '请输入角色类型名称（必填）',
    },
  },
  {
    field: 'code',
    label: '角色类型编号',
    required: true,
    component: 'Input',
    componentProps: {
      placeholder: '请输入角色类型名称（必填）',
    },
  },
  {
    field: 'description',
    label: '角色类型描述',
    component: 'Input',
    componentProps: {
      placeholder: '请输入角色类型描述（选填）',
    },
  },
  {
    field: 'typeCode',
    label: '角色对象类型',
    required: true,
    component: 'dictSelect',
    componentProps: {
      placeholder: '请选择角色对象类型（必选）',
      code: 'ROLE_TYPE'
    },
  },
  {
    field: 'organizationId',
    label: '所属机构',
    required: true,
    component: 'rwTreeSelect',
    componentProps: ({ formModel }) => {
      return {
        type: 'org',
        value: formModel.organizationId
      }
    }
  },
  {
    field: 'remark',
    label: '备注',
    component: 'InputTextArea',
    colProps: { lg: 24, md: 24 },
    componentProps: {
      placeholder: '请输入备注',
    },
  },
  {
    field: 'isEnable',
    label: '是否生效',
    component: 'Switch',
    defaultValue: true,
    colProps: { lg: 24, md: 24 },
  },
];
